/*******************
Define 5 large groups
Group 1: Catering and Entertainment
Group 2: General
Group 3: General (wholesales + real estate and auto) with cap
Group 4: Discount
Group 5: Public
********************/

* Catering and entertainment
gen group5 = 1 if code4_s == "5094" | code4_s == "5811" | code4_s == "5812" | code4_s == "5813"| code4_s == "5932"| code4_s == "5937"|code4_s == "5944" ///
| code4_s == "5970"|  code4_s == "5950"| code4_s == "5971"

replace group5 = 1 if code4_s == "7011"| code4_s == "7012"| code4_s == "7032"| code4_s == "7033"| code4_s == "7631"| code4_s == "7829" | code4_s == "7911"  ///
| code4_s == "7922"| code4_s == "7297"| code4_s == "7298"| code4_s == "7929"| code4_s == "7932"| code4_s == "7933"| code4_s == "7941" | code4_s == "7992" ///
| code4_s == "7996"| code4_s == "7997" | code4_s == "7998"| code4_s == "7999"


* General
replace group5 = 2 if code4_s == "4733"| code4_s == "4722"| code4_s == "5814"| code4_s == "0742"| code4_s == "0763"| code4_s == "0780"| code4_s == "4011" ///
| code4_s == "4119" | code4_s == "4214"| code4_s == "4215"| code4_s == "4225" | code4_s == "4411"| code4_s == "4457"| code4_s == "4468"| code4_s == "4582" ///
| code4_s == "4789" | code4_s == "4812" | code4_s == "4816"| code4_s == "4821"

replace group5 = 2 if code4_s == "5211"| code4_s == "5231"| code4_s == "5251"| code4_s == "5261"| code4_s == "5309"| code4_s == "5310" | code4_s == "5311" ///
| code4_s == "5331"| code4_s == "5399"| code4_s == "5422"| code4_s == "5441"| code4_s == "5451" | code4_s == "5462"| code4_s == "5499" | code4_s == "5532" ///
| code4_s == "5533"| code4_s == "5611"| code4_s == "5621"| code4_s == "5631"| code4_s == "5641" | code4_s == "5651"| code4_s == "5655" | code4_s == "5661" ///
| code4_s == "5681"| code4_s == "5691"| code4_s == "5697"| code4_s == "5698"| code4_s == "5699" | code4_s == "5712"| code4_s == "5713" | code4_s == "5714" ///
| code4_s == "5718"| code4_s == "5719"| code4_s == "5732"| code4_s == "5733"| code4_s == "5734" | code4_s == "5735"| code4_s == "5912" | code4_s == "5921" ///
| code4_s == "5931"| code4_s == "5935"| code4_s == "5940"| code4_s == "5941"| code4_s == "5942" | code4_s == "5943" | code4_s == "5945"| code4_s == "5946" ///
| code4_s == "5947"| code4_s == "5948"| code4_s == "5949"| code4_s == "5962"| code4_s == "5963" | code4_s == "5964" | code4_s == "5965"| code4_s == "5966" ///
| code4_s == "5967"| code4_s == "5968"| code4_s == "5969"| code4_s == "5972"| code4_s == "5973" | code4_s == "5975" | code4_s == "5976"| code4_s == "5977" ///
| code4_s == "5978"| code4_s == "5983"| code4_s == "5992"| code4_s == "5993"| code4_s == "5995" | code4_s == "5996" | code4_s == "5997"| code4_s == "5999"

replace group5 = 2 if code4_s == "6010"| code4_s == "6011"| code4_s == "6012"| code4_s == "6051"| code4_s == "6211" | code4_s == "6513"

replace group5 = 2 if code4_s == "7210"| code4_s == "7211" | code4_s == "7216"| code4_s == "7217"| code4_s == "7221"| code4_s == "7230"| code4_s == "7251" ///
| code4_s == "7261"| code4_s == "7273"| code4_s == "7276"| code4_s == "7277"| code4_s == "7278"| code4_s == "7295"| code4_s == "7296"| code4_s == "7299" ///
| code4_s == "7311"| code4_s == "7321"| code4_s == "7333"| code4_s == "7338"| code4_s == "7339"| code4_s == "7342"| code4_s == "7349"| code4_s == "7361" ///
| code4_s == "7372"| code4_s == "7375"| code4_s == "7379"| code4_s == "7392"| code4_s == "7393"| code4_s == "7394"| code4_s == "7395"| code4_s == "7399" ///
| code4_s == "7512"| code4_s == "7513"| code4_s == "7519"| code4_s == "7531"| code4_s == "7534"| code4_s == "7535"| code4_s == "7538"| code4_s == "7542" ///
| code4_s == "7549"| code4_s == "7622"| code4_s == "7623"| code4_s == "7629"| code4_s == "7641"| code4_s == "7692"| code4_s == "7699"| code4_s == "7832" ///
| code4_s == "7841"| code4_s == "7991"| code4_s == "7993"| code4_s == "7995" 

replace group5 = 2 if code4_s == "8011"| code4_s == "8021" | code4_s == "8031" | code4_s == "8041" | code4_s == "8042" ///
| code4_s == "8043" | code4_s == "8049"| code4_s == "8050" | code4_s == "8071" | code4_s == "8099" | code4_s == "8111" | code4_s == "8241" | code4_s == "8244" ///
| code4_s == "8249" | code4_s == "8299"| code4_s == "8351" | code4_s == "8641" | code4_s == "8661" | code4_s == "8675" | code4_s == "8699" | code4_s == "8911" ///
| code4_s == "8912" | code4_s == "8931"| code4_s == "8999"


* Wholesales
replace group5 = 3 if code4_s == "5398" | code4_s == "4458" | code4_s == "5013" | code4_s == "5021" ///
| code4_s == "5039"| code4_s == "5044"| code4_s == "5045"| code4_s == "5046"| code4_s == "5047"| code4_s == "5051"| code4_s == "5065"| code4_s == "5072" ///
| code4_s == "5074"| code4_s == "5111"| code4_s == "5122"| code4_s == "5131"| code4_s == "5137"| code4_s == "5139"| code4_s == "5172"| code4_s == "5192" ///
| code4_s == "5193"| code4_s == "5198"| code4_s == "5998" 
 
 
* Auto & Real estate
replace group5 = 3 if code4_s == "1520" | code4_s == "5271" | code4_s == "5511" | code4_s == "5521"| code4_s == "5551"| ///
| code4_s == "5561" | code4_s == "5571" | code4_s == "5592" | code4_s == "5598" | code4_s == "5599"| code4_s == "5933"| code4_s == "7013"


* Livlihood: Supermarket, Transportation, Utilities, Public Services, Kiosk
replace group5 = 4 if code4_s == "5411" | code4_s == "5722" | code4_s==  "5542" | code4_s == "5541" | code4_s == "5200" | code4_s == "5300" |  ///   
code4_s == "4111" | code4_s == "4121" | code4_s == "4131" | code4_s == "4511" | code4_s == "4784" | code4_s == "4112" | code4_s == "3998" | ///
code4_s == "4900" | code4_s == "5960" | code4_s == "6300" | code4_s == "4814" | code4_s == "4899" | ///
code4_s == "9311" | code4_s == "9399" | code4_s == "5994" 


* Non-profit: Mostly public hospital
replace group5 = 5 if code4_s == "8062" | code4_s == "8220"


/*******************
Define 87 groups
********************/

gen group87 = 1 if code4_s == "4011" 
replace group87 = 2 if code4_s == "4111" 
replace group87 = 3 if code4_s == "4121" 
replace group87 = 4 if code4_s == "4225" 
replace group87 = 5 if code4_s == "4411" 
replace group87 = 6 if code4_s == "4215" 
replace group87 = 7 if code4_s == "4789" 
replace group87 = 8 if code4_s == "4722" 
replace group87 = 9 if code4_s == "4812" 
replace group87 = 10 if code4_s == "4814" 
replace group87 = 11 if code4_s == "4815" 
replace group87 = 12 if code4_s == "4816" 
replace group87 = 13 if code4_s == "4899" 
replace group87 = 14 if code4_s == "5211" 
replace group87 = 15 if code4_s == "5094" 
replace group87 = 16 if code4_s == "5932"
replace group87 = 17 if code4_s == "5812"
replace group87 = 18 if code4_s == "5813" 
replace group87 = 19 if code4_s == "5970" 
replace group87 = 20 if code4_s == "7011" 
replace group87 = 21 if code4_s == "7941" 
replace group87 = 22 if code4_s == "7998" | code4_s == "7996"
replace group87 = 23 if code4_s == "4582" | code4_s == "4511" 
replace group87 = 24 if code4_s == "5411" 
replace group87 = 25 if code4_s == "5311" 
replace group87 = 26 if code4_s == "5399" 
replace group87 = 27 if code4_s == "1520" 
replace group87 = 28 if code4_s == "5271" | code4_s == "5511" 
replace group87 = 29 if code4_s == "5998" 
replace group87 = 30 if code4_s == "5441"
replace group87 = 31 if code4_s == "5451" 
replace group87 = 32 if code4_s == "5541" 
replace group87 = 33 if code4_s == "5462" 
replace group87 = 34 if code4_s == "5532" | code4_s == "5533" 
replace group87 = 35 if code4_s == "5542" 
replace group87 = 36 if code4_s == "5611" | code4_s == "5621" | code4_s == "5631" | code4_s == "5641"
replace group87 = 37 if code4_s == "5691" | code4_s == "5699" | code4_s == "5681" 
replace group87 = 38 if code4_s == "5661"
replace group87 = 39 if code4_s == "5714" | code4_s == "5719" | code4_s == "5231" 
replace group87 = 40 if code4_s == "5722" 
replace group87 = 41 if code4_s == "5732" 
replace group87 = 42 if code4_s == "5733" 
replace group87 = 43 if code4_s == "5734" 
replace group87 = 44 if code4_s == "5814" 
replace group87 = 45 if code4_s == "5912" 
replace group87 = 46 if code4_s == "5941" 
replace group87 = 47 if code4_s == "5942" 
replace group87 = 48 if code4_s == "5943" 
replace group87 = 49 if code4_s == "5946" 
replace group87 = 50 if code4_s == "5947" | code4_s == "5948" | code4_s == "5976" 
replace group87 = 51 if code4_s == "5977" 
replace group87 = 52 if code4_s == "5992" 
replace group87 = 53 if code4_s == "5993" 
replace group87 = 54 if code4_s == "5994" 
replace group87 = 55 if code4_s == "7210" 
replace group87 = 56 if code4_s == "7299" 
replace group87 = 57 if code4_s == "7221" 
replace group87 = 58 if code4_s == "7297" | code4_s == "7298" | code4_s == "7230" | code4_s == "8014" 
replace group87 = 59 if code4_s == "7261" 
replace group87 = 60 if code4_s == "7277" 
replace group87 = 61 if code4_s == "7311" 
replace group87 = 62 if code4_s == "7321" 
replace group87 = 63 if code4_s == "7339" | code4_s == "7399" 
replace group87 = 64 if code4_s == "7333" 
replace group87 = 65 if code4_s == "7372" 
replace group87 = 66 if code4_s == "7392"
replace group87 = 67 if code4_s == "7832" 
replace group87 = 68 if code4_s == "7622" 
replace group87 = 69 if code4_s == "7512"
replace group87 = 70 if code4_s == "7538" | code4_s == "7542" | code4_s == "7519" 
replace group87 = 71 if code4_s == "7631"
replace group87 = 72 if code4_s == "7699" 
replace group87 = 73 if code4_s == "7841" 
replace group87 = 74 if code4_s == "7911" | code4_s == "7997" 
replace group87 = 75 if code4_s == "7933"
replace group87 = 76 if code4_s == "7993" | code4_s == "7999" 
replace group87 = 77 if code4_s == "8042" | code4_s == "8043" 
replace group87 = 78 if code4_s == "8050" 
replace group87 = 79 if code4_s == "8062" 
replace group87 = 80 if code4_s == "8011" | code4_s == "8021" | code4_s == "8099" 
replace group87 = 81 if code4_s == "8111" 
replace group87 = 82 if code4_s == "8211" 
replace group87 = 83 if code4_s == "8220" 
replace group87 = 84 if code4_s == "8299" 
replace group87 = 85 if code4_s == "8351" 
replace group87 = 86 if code4_s == "8911" | code4_s == "8912" 
